package com.honeycomb.common;

import java.io.Serializable;


public class PositionInfo implements Serializable {
	
	private PositionType type = PositionType.NORMAL;
	
	private double longitude;
	private double latitude;
	private String address;
	private int mapProviderId;

	public PositionInfo() {}
	
	public PositionInfo(double lng, double lat, String addr, int providerId) {
		this.longitude = lng;
		this.latitude = lat;
		this.address = addr;
		this.mapProviderId = providerId;
	}
	
	
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public int getMapProviderId() {
		return mapProviderId;
	}
	public void setMapProviderId(int mapProviderId) {
		this.mapProviderId = mapProviderId;
	}
	public PositionType getType() {
		return type;
	}
	public void setType(PositionType type) {
		this.type = type;
	}

	public enum PositionType {
		// 越重要的类型值越小，方便数据库排序显示
		DEFAULT(10),
		FAVOUR(20),
		NORMAL(30);
		
		private int intValue;
		
		private PositionType(int intValue) {
			this.intValue = intValue;
		}
		
		/**
		 * 根据传入INT值来返回对应的状态类型
		 */
		public static PositionType getPositionType(int intValue) {
			for (PositionType elem : PositionType.values()) {
				if (elem.toIntValue() == intValue) {
					return elem;
				}
			}

			throw new IllegalArgumentException("Value '" + intValue
					+ "' is not allowed in PositionType.");
		}

		/**
		 * 返回int值类型。
		 * @return
		 */
		public int toIntValue() {
			return intValue;
		}
	};
	
}
